using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.IO;
using System.Reflection;

namespace MyLib
{
    public class ResourceUtil
    {
        public static Image GetResourceImage(Type type, string resourceName)
        {
            Stream stream = GetResourceStream(type, resourceName);
            if (stream != null)
            {
                return Image.FromStream(stream);
            }
            return null;
        }

        public static Stream GetResourceStream(Type type, string resourceName)
        {
            Assembly ass = Assembly.Load(type.Assembly.FullName);
            Stream stream = ass.GetManifestResourceStream(resourceName);
            return stream;
        }

        public static Stream GetResourceStream(string assemblyName, string resourceName)
        {
            Assembly ass = Assembly.Load(assemblyName);
            if (ass != null)
            {
                Stream stream = ass.GetManifestResourceStream(resourceName);
                return stream;
            }
            return null;
        }
    }
}
